package com.io.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.io.exception.AspectUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

/**
 * The class/interface
 *
 * @author guodd
 * @version 1.0 use jdk 1.8
 */
@Aspect
@Component
public class ControllerAspect {
    @Autowired
    private ObjectMapper objectMapper;

    @Autowired
    private Environment environment;

    @Around("execution(public * com.io.controller..*Controller.*(..))")
    public Object around(ProceedingJoinPoint pjp) throws Throwable {
        return AspectUtils.controllerAspect(pjp, objectMapper, environment);
    }
}
